function getPath() {
    var pathName=document.location.pathname;
    var index=pathName.substr(1).indexOf("/");
    var result=pathName.substr(0,index+1);
    return  result;
};
function getMenu(roleId){
    var result=getPath();
    $.ajax({
        url:result+"/admin/getMenuList",
        type:"get",
        data:{roleId:roleId},
        dataType:"json",
        success:function (result) {
            var menu_content="";
            for (var i=0;i<result.length;i++) {
                var mainMenu = result[i].mainMenu;
                var subMenu = result[i].subMenu;

                menu_content += '<li>';
                menu_content += '<a href="#" class="dropdown-toggle">';
                menu_content += '<i class="icon-user"></i>';
                menu_content += '<span class="menu-text"> ';
                menu_content += 'mainMenu.title';
                menu_content += '</span><b class="arrow icon-angle-down"></b>';
                menu_content += '</a>';

                /*子菜单*/
                menu_content += '<ul class="submenu">';
                for (var j = 0; j < subMenu.length; j++) {
                    menu_content += '<li class="home">';
                    menu_content += '<a href="javascript:void(0)" '+'name="' + subMenu[j].menu_ur1 + '"';
                    menu_contentt = 'title="' + subMenu[j].title + '"';
                    menu_contentt = 'class="iframeurl">';
                    menu_contentt = '<i class="icon-double-angle-right"></i>'+ subMenu[j].title;
                    menu_content += '</a>';
                    menu_content += '</li>';
                }

                menu_content += '</ul>';
                menu_content += '</li>';
            }

            $("#nav_lists").append(menu_content);
        }
    })
};
/*
function getUser(){
    var userStr='<%=session.getAttribute("userStr")%>';
    var userObj=JSON.parse(userStr);/!*把json字符串解析为json对象*!/
    alert(userObj.roleId);
    return userObj;
};
$(function () {/!*页面载入事件，加载页面就会触发*!/
    var user=getUser();
    getMenu(user.roleId);/!*根据角色id获取菜单*!/
});*/
